@import "../../styles/variables.scss";
@import "../../styles/mixins";

.select {
  position: relative;
  width: $input-default-width;

  &-control {
    position: relative;
    display: table;
    width: 100%;
    height: 32px;
    padding: 0 12px;
    border: 1px solid $input-border-color;
    border-radius: $border-radius;
    background-color: $white;
    transition: border-color $trans-speed ease-in-out;
    box-sizing: border-box;
    cursor: pointer;

    &:hover {
      border-color: $input-hover-color;
    }

    &:focus {
      border-color: $input-focus-color;
      box-shadow: $input-focus-shadow;
    }
  }

  &.is-open .select-control {
    border-color: $input-focus-color;
    box-shadow: $input-focus-shadow;
  }

  &-value-wrapper {
    position: relative;
    display: table-cell;
    vertical-align: middle;

    .select-value,
    .select-placeholder {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      display: inline-flex;
      align-items: center;
      max-width: 100%;
      @include TypographySymbolText;
      @include ellipsis;
    }

    .select-value-opacity {
      opacity: 0;
    }
  }

  &-icon {
    position: relative;
    display: table-cell;
    width: 16px;
    height: 100%;
    padding-left: 4px;

    &-item {
      align-items: center;
      display: flex;
      height: 100%;

      & > span {
        align-self: center;
      }
    }

    &-check {
      text-size-adjust: 100%;
      display: flex;
      box-sizing: border-box;
      padding: 4px 12px;
      cursor: pointer;
      justify-content: space-between;
      color: $text-color;
      background-color: $light-color02;
    }

    &-prefixIcon {
      padding-left: 0px;
      padding-right: 6px;
    }
  }

  &-input {
    height: 20px;
    overflow: hidden;
    vertical-align: middle;
    box-sizing: border-box;
    position: relative;
    margin-left: 0.5px;
    line-height: 20px;

    & > input {
      margin: 0;
      padding: 0;
      border: none;
      outline: none;
      width: 100%;
      background: 0 0;
      cursor: pointer;
      @include TypographySymbolText;

      &::placeholder {
        font-weight: $font-normal;
        color: $input-placeholder-color;
      }
    }

    &-search {
      position: absolute;
      top: 0;
      left: 0;
      z-index: 999;
      white-space: nowrap;
      visibility: hidden;
    }
  }

  &-input-opacity {
    opacity: 0;
  }

  &-options {
    position: fixed;
    max-height: 232px;
    margin-top: 4px;
    padding: 4px 0;
    border-radius: $border-radius;
    background-color: $heading-color;
    box-shadow: 0 4px 8px 0 rgba(36, 46, 66, 0.16);
    box-sizing: border-box;
    overflow-y: auto;
    z-index: 1000;

    .select-option {
      display: flex;
      padding: 6px 12px;
      @include TypographyParagraph($white);
      font-family: $font-family-id;
      box-sizing: border-box;
      cursor: pointer;

      &-active,
      &:hover {
        background: $dark-color06;
        font-weight: $font-bold;
      }

      &-disabled {
        color: $dark-color01;
        cursor: not-allowed;
      }

      & > label.checkbox {
        margin-right: 8px;
      }

      &-label {
        flex-grow: 1;
        text-align: left;
        @include ellipsis;
      }

      &-icon {
        color: $text-color;
        box-sizing: inherit;
        display: inline-flex;
        align-items: center;

        & > .icon {
          align-self: center;
        }
      }
    }

    .select-group-option {
      text-align: center;

      & > .select-group-title {
        margin: 0;
        padding: 0 12px;
        height: 32px;
        line-height: 32px;
        color: $dark-color01;
        font-size: 12px;
        text-align: left;
      }

      &::after {
        display: block;
        content: "";
        height: 1px;
        width: auto;
        margin: 0 10px;
        margin-top: -1px;
        background-color: $dark-color06;
      }

      &:last-child::after {
        display: none;
      }
    }

    &-loading {
      padding: 20px 0;
      text-align: center;
    }

    &-empty {
      padding: 20px 0;
      text-align: center;
      color: $white;
    }
  }

  &-multi {
    position: relative;
    box-sizing: border-box;

    .select-control {
      vertical-align: bottom;
    }

    .select-input-multi {
      display: inline-block;

      & > input {
        border: 0px;
        width: 1px;
        display: inline-block;
      }
    }

    .select-value-wrapper {
      padding: 2px 0;
      line-height: 25px;
    }

    .select-multi-value {
      display: table-cell;
      vertical-align: middle;

      &-item {
        height: auto;
        padding: 0;
        margin-right: 10px;
        margin-left: -4px;

        & > span {
          display: inline-flex;
          height: 20px;
          padding: 0 4px;
          background: $heading-color;
          border-radius: 2px;
          align-items: center;
          justify-content: center;
          white-space: nowrap;
          outline: none;
          cursor: pointer;
        }

        &-label {
          padding-right: 8px;
          font-weight: normal;
          cursor: default;
          color: $white;
        }

        &-icon {
          display: inline-flex;
          align-items: center;
          width: 16px;
          cursor: pointer;
        }
      }
    }
  }

  &-disabled {
    .select-control {
      opacity: 0.5;
      cursor: not-allowed;
      background-color: $input-disabled-color;
    }

    .select-input input {
      cursor: not-allowed;
    }

    .select-icon {
      cursor: not-allowed;
    }
  }
}
